﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;

namespace Apq.Web.UI
{
	/// <summary>
	/// 常用功能
	/// <![CDATA[登录超时处理]]>
	/// </summary>
	public class BasePage : System.Web.UI.Page
	{
		/// <summary>
		/// 语言版本
		/// </summary>
		protected string Lang;

		/// <summary>
		/// 指示该页面是否必须登录后才能查看
		/// </summary>
		protected bool RequiredLogin;

		protected Apq.Web.SessionState.HttpSessionState ApqSession = null;

		/// <summary>
		/// BasePage
		/// </summary>
		public BasePage()
		{
			Load += new EventHandler(Page_Load);
		}

		/// <summary>
		/// BasePage
		/// </summary>
		public BasePage(bool RequiredLogin)
			: this()
		{
			this.RequiredLogin = RequiredLogin;
		}

		/// <summary>
		/// Page_Load
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void Page_Load(object sender, EventArgs e)
		{
			Lang = base.Request.Cookies["lang"] == null ? "en" : base.Request.Cookies["lang"].Value;
			ApqSession = new SessionState.HttpSessionState(Session);

			if (RequiredLogin && ApqSession.ApqLogin.LoginStatus == 0)
			{
				Response.Redirect("~/Default.aspx", true);
			}
		}
	}
}
